package com.chenfeng.ego.portal.service.impl;

import java.util.HashMap;
import java.util.Map;

import javax.annotation.Resource;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;

import com.chenfeng.ego.commons.util.HttpClientUtil;
import com.chenfeng.ego.commons.util.JsonUtils;
import com.chenfeng.ego.portal.pojo.TbItemImages;
import com.chenfeng.ego.portal.service.TbItemImageService;
@Service
public class TbItemImageServiceImpl implements TbItemImageService
{

	@Value("${itemDetailUrl}")
	private String url;
	@Override
	//商品详情的展示
	public TbItemImages selById(long id)
	{
		Map<String,String> map = new HashMap<>();
		map.put("id", id+"");
		String result = HttpClientUtil.doPost(url,map);
		System.out.println(result);
		TbItemImages images = JsonUtils.jsonToPojo(result, TbItemImages.class);
		String image = images.getImage();
		images.setImages(image!=null?image.split(","):new String[0]);
		return images;
	}

}
